package com.dingwen.treasure.manage.controller;

import com.dingwen.treasure.base.pojo.vo.Result;
import com.dingwen.treasure.manage.dto.SysElementDto;
import com.dingwen.treasure.manage.vo.SysElementVo;
import com.dingwen.treasure.model.entity.mybatisplus.SysElement;
import com.dingwen.treasure.mybatisplus.controller.AbstractBaseControllerMybatisPlusImpl;
import com.dingwen.treasure.mybatisplus.service.SysElementService;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 　SysElementController
 * 　@author dingwen
 * 　@date 2022/6/21
 */
@Api(tags = "系统菜单元素,基于mybatis-plus封装BaseController")
@ApiSupport(author = "dingwen")
@Slf4j
@RestController
@RequestMapping("sys/element")
public class SysElementController extends AbstractBaseControllerMybatisPlusImpl<SysElement, SysElementDto,
        SysElementVo> {

    /**
     * sysElementService
     */
    @Resource
    private SysElementService sysElementService;

    /**
     * 按用户id获取系统元素
     *
     * @param userId 用户id
     * @return {@link Result}<{@link List}<{@link SysElement}>>
     */
    @ApiOperation(value = "根据用户Id查询元素信息")
    @ApiImplicitParam(value = "用户Id", name = "userId")
    @GetMapping("/feign/{userId}")
    public Result<List<SysElement>> getSysElementsByUserId(@PathVariable Long userId) {
        List<SysElement> sysElements = sysElementService.getSysElementsByUserId(userId);
        return success(sysElements);
    }
}
